package close.mazegame;

import close.mazegame.art.MiscArt;
import close.mazegame.screens.Screen;
import close.mazegame.screens.TitleScreen;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;

public class MazeGame extends ApplicationAdapter {

	public static final int WIDTH = 1280;
	public static final int HEIGHT = 720;
	
	private boolean running = false;

	private Screen screen;
	
	@Override
	public void create() {
		running = true;
		InputHandler.create();
		MiscArt.load();
		setScreen(new TitleScreen());
	}
	
	@Override
	public void render() {
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		screen.update(Gdx.graphics.getDeltaTime());
		screen.render();
		if (Debug.showFPS()) {
			screen.drawFPS();
		}
		InputHandler.reset(); //Resets typed keys
	}
	
	public void setScreen(Screen newScreen) {
		if (screen != null && !newScreen.isOverlay()) {
			screen.dispose();
		}
		screen = newScreen;
		if (screen != null) {
			screen.init(this);
		}
	}

	@Override
	public void resize(int width, int height) {
	}
	
	public boolean isRunning(){
		return running;
	}

	@Override
	public void pause() {
		running = false;
	}

	@Override
	public void resume() {
		running = true;
	}

	@Override
	public void dispose() {
		screen.dispose();
	}

}
